/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

/**
 *
 * @author Nevermade
 */
public class TestPanel extends javax.swing.JPanel {
    private BufferedImage img=null;
    public int secX=0;
    public int secY=0;
    public int step=10;
    /**
     * Creates new form TestPanel
     */
    public TestPanel() {
        initComponents();
    }
    
    @Override
    public void paintComponent(Graphics g){
        if(img==null){
            try{
                img=ImageIO.read(getClass().getResource("/testImage.jpg"));
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        if(secX<0) secX=0;
        else if(secX>img.getWidth()-200)secX=img.getWidth()-200;
        else if(secY<0) secY=0;
        else if(secY>img.getHeight()-200)secY=img.getHeight()-200;
        BufferedImage section=img.getSubimage(secX, secY, 200, 200);
        g.drawImage(section, 0, 0, this);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
